package com.costeaalex.datedrivenfilecopy.model.erasers;

/**
 * @author Alex Costea
 * 
 * Class that handles erasing operations on the local system.
 * 
 */

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;

import com.costeaalex.datedrivenfilecopy.model.interfaces.IEraser;

public class NormalEraser implements IEraser {

	@Override
	public void init() {
		
	}

	@Override
	public boolean delete(EraseFile file) {
		File f=new File(file.getStringPath());
		f.delete();
		return false;
	}
	
	@Override
	public ArrayList<EraseFile> getFileList(EraseFile file) {
		String[] files=(new File(file.getStringPath())).list();
		ArrayList<EraseFile> aL=new ArrayList<EraseFile>();
		
		for(int i=0; i<files.length; i++)
			aL.add(new EraseFile(file.getStringPath().replace("\\", "/")+"/"+files[i], Files.isDirectory(Paths.get(file.getStringPath().replace("\\", "/")+"/"+files[i]))));

		return aL;
	}

	@Override
	public void destroy() {
			
	}
}
